<?php
/**
 * Created by PhpStorm.
 * User: fengyan
 * Date: 17-10-26
 * Time: 上午11:15
 */

namespace App\Http\Middleware;

use App\Exceptions\MyException;
use App\Helpers;
use Closure;
class EntrustRole extends \Zizaco\Entrust\Middleware\EntrustRole
{
    use Helpers\Jump;

    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  Closure $next
     * @param  $roles
     * @return mixed
     */
    public function handle($request, Closure $next, $roles)
    {
        if ($this->auth->guest() || !$request->user()->hasRole(explode('|', $roles))) {
//            abort(403, "您没有访问权限");
            return $this->setCurrentModule('admin')->error('您没有权限访问');
        }

        return $next($request);
    }
}